package com.yxkj.syh.app.huarong.bean;


import android.text.TextUtils;

import com.syh.app.basic.App;
import com.yxkj.syh.app.huarong.R;
import com.yxkj.syh.app.huarong.constants.OrderStatus;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 采购单
 * </p>
 *
 * @author dengyejun
 * @since 2020-04-24
 */
public class OrderInfo implements Serializable {

    private Long id;

    //    @ApiModelProperty(name = "creatorId", value = "创建人id")
    private Long creatorId;

    //    @ApiModelProperty(name = "carId", value = "车辆id")
    private Long carId;
    //    @ApiModelProperty(name = "carId", value = "车辆No.")
    private String carNo;

    //    @ApiModelProperty(name = "carId", value = "司机手机 联系方式")
    private String carPhone;

    //    @ApiModelProperty(name = "semitrailerNo", value = "挂车牌号")
    private String semitrailerNo;

    //    @ApiModelProperty(name = "lineType", value = "线路类型", notes = "0-直达车，1-回头车")
    private Integer lineType = 0;

    //    @ApiModelProperty(name = "startAreaIds", value = "发货地省市区Ids")
    private String startAreaIds;

    //    @ApiModelProperty(name = "startArea", value = "发货地省市区")
    private String startArea;

    //    @ApiModelProperty(name = "startAddress", value = "发货地详细地址")
    private String startAddress;

    //    @ApiModelProperty(name = "endAreaIds", value = "目的地省市区Ids")
    private String endAreaIds;

    //    @ApiModelProperty(name = "endArea", value = "目的地省市区")
    private String endArea;

    //    @ApiModelProperty(name = "endAddress", value = "目的地详细地址")
    private String endAddress;

    //   0-采购，1-其他
    private int originType = 1;

    private int isEmpty;//0 否 1是

    private int status;
    private int expensesExists;

    private String createTime;
    private String updateTime;
    private String no;
    private String remark;
    private String statusTime;
    private String label;


    public int getOriginType() {
        return originType;
    }

    public void setOriginType(int originType) {
        this.originType = originType;
    }

    //    @ApiModelProperty(name = "orderProductList", value = "货运单商品信息集合")
    private List<Goods> orderProductList;
    //    @ApiModelProperty(name = "orderProductList", value = "货运单商品信息集合")
    private List<OrderProcess> orderProcessList;

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getCreatorId() {
        return creatorId;
    }

    public void setCreatorId(Long creatorId) {
        this.creatorId = creatorId;
    }

    public Long getCarId() {
        return carId;
    }

    public void setCarId(Long carId) {
        this.carId = carId;
    }

    public String getSemitrailerNo() {
        return semitrailerNo;
    }

    public void setSemitrailerNo(String semitrailerNo) {
        this.semitrailerNo = semitrailerNo;
    }

    public Integer getLineType() {
        return lineType;
    }

    public void setLineType(Integer lineType) {
        this.lineType = lineType;
    }

    public String getStartAreaIds() {
        return startAreaIds;
    }

    public void setStartAreaIds(String startAreaIds) {
        this.startAreaIds = startAreaIds;
    }

    public String getStartArea() {
        if (!TextUtils.isEmpty(startArea)){
            return startArea.replace("/","");
        }
        return startArea;
    }

    public void setStartArea(String startArea) {
        this.startArea = startArea;
    }

    public String getStartAddress() {
        return startAddress;
    }

    public void setStartAddress(String startAddress) {
        this.startAddress = startAddress;
    }

    public String getEndAreaIds() {
        return endAreaIds;
    }

    public void setEndAreaIds(String endAreaIds) {
        this.endAreaIds = endAreaIds;
    }

    public String getEndArea() {
        if (!TextUtils.isEmpty(endArea)){
            return endArea.replace("/","");
        }
        return endArea;
    }

    public void setEndArea(String endArea) {
        this.endArea = endArea;
    }

    public String getEndAddress() {
        return endAddress;
    }

    public void setEndAddress(String endAddress) {
        this.endAddress = endAddress;
    }

    public List<Goods> getOrderProductList() {
        return orderProductList;
    }


    public void setOrderProductList(List<Goods> orderProductList) {
        this.orderProductList = orderProductList;
    }

    public String getCarNo() {
        return carNo;
    }

    public void setCarNo(String carNo) {
        this.carNo = carNo;
    }

    public String getCarPhone() {
        return carPhone;
    }

    public void setCarPhone(String carPhone) {
        this.carPhone = carPhone;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }

    public List<OrderProcess> getOrderProcessList() {
        return orderProcessList;
    }

    public void setOrderProcessList(List<OrderProcess> orderProcessList) {
        this.orderProcessList = orderProcessList;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getStatusTime() {
        return statusTime;
    }

    public void setStatusTime(String statusTime) {
        this.statusTime = statusTime;
    }

    public int getExpensesExists() {
        return expensesExists;
    }

    public void setExpensesExists(int expensesExists) {
        this.expensesExists = expensesExists;
    }

    public String getGoodsListStr() {
        if (TextUtils.isEmpty(label)){
            return "";
        }
        return label.replace("|", "\n");
    }

    public int getIsEmpty() {
        return isEmpty;
    }

    public void setIsEmpty(int isEmpty) {
        this.isEmpty = isEmpty;
    }

    /* *************************************************************************************************** */

    public String getStatusText() {
        switch (status) {
            case OrderStatus
                    .WAIT_SHIPMENTS:
                return "待发车";//待发车
            case OrderStatus
                    .ALREADY_SHIPMENTS:
                return "运输中";//运输中
            case OrderStatus
                    .ALREADY_RECEIVING:
                return "已签收";//已签收
            case OrderStatus
                    .ALREADY_INVALID:
                return "已取消";//已取消
        }
        if (status>2){
            return "已签收";
        }
        return "--";
    }

    public int statusTextColor() {
        switch (status) {
            case OrderStatus.WAIT_SHIPMENTS:
            case OrderStatus.ALREADY_SHIPMENTS:
            case OrderStatus.ALREADY_RECEIVING:
                return App.getApplication().getColor(R.color.defaultOrange);
            case OrderStatus.ALREADY_INVALID:
                return App.getApplication().getColor(R.color.textColor5);

            default:
                return App.getApplication().getColor(R.color.defaultOrange);
        }
    }

    public String getDateString() {

        return statusTime;
    }


    public Map<String, Object> getCreatRequest() {
        Map<String, Object> pMap = new HashMap<>();
        pMap.put("carId", carId);
        pMap.put("carNo", carNo);
        pMap.put("endAddress", endAddress);
        pMap.put("endArea", endArea);
        pMap.put("endAreaIds", endAreaIds);
        pMap.put("lineType", lineType);
        pMap.put("semitrailerNo", semitrailerNo);
        pMap.put("startAddress", startAddress);
        pMap.put("startArea", startArea);
        pMap.put("startAreaIds", startAreaIds);
        pMap.put("originType", originType);

        List<Map<String, Object>> goodsMapList = new ArrayList<>();
        for (Goods temp : orderProductList) {
            Map<String, Object> goodsMap = new HashMap<>();
            goodsMap.put("name", temp.getName());
            goodsMap.put("weight", temp.getWeight());
            goodsMap.put("productId", temp.getProductId());
            goodsMap.put("productNo", temp.getNo());
            goodsMap.put("isReturn", temp.getIsReturn());
            goodsMapList.add(goodsMap);
        }
        pMap.put("orderProductList", goodsMapList);

        return pMap;
    }

    public Map<String, Object> getOutCreatRequest() {
        Map<String, Object> pMap = new HashMap<>();
        pMap.put("carNo", carNo);
        pMap.put("carPhone", carPhone);
        pMap.put("endAddress", endAddress);
        pMap.put("endArea", endArea);
        pMap.put("endAreaIds", endAreaIds);
        pMap.put("semitrailerNo", semitrailerNo);
        pMap.put("startAddress", startAddress);
        pMap.put("startArea", startArea);
        pMap.put("startAreaIds", startAreaIds);

        List<Map<String, Object>> goodsMapList = new ArrayList<>();
        for (Goods temp : orderProductList) {
            Map<String, Object> goodsMap = new HashMap<>();
            goodsMap.put("name", temp.getName());
            goodsMap.put("weight", temp.getWeight());
            goodsMap.put("productId", temp.getProductId());
            goodsMap.put("productNo", temp.getNo());
            goodsMap.put("isReturn", temp.getIsReturn());
            goodsMapList.add(goodsMap);
        }
        pMap.put("orderProductList", goodsMapList);

        return pMap;
    }
}
